package com.bdqn.spark.chapter05.value

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark06_RDD_Operator_Transform_test1 {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("operator-groupby")
    val sc = new SparkContext(sparkConf)

    // 算子 - groupBy
    val rdd  = sc.makeRDD(List("Hello", "Spark", "Scala", "Hadoop"), 2)

    val resultRDD: RDD[(Char, Iterable[String])] = rdd.groupBy(
      word => {
        word.charAt(0)
      }
    )

    resultRDD.collect().foreach(println)

    sc.stop()
  }
}
